# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
import time
import urllib.request
# useful for handling different item types with a single interface
from itemadapter import ItemAdapter


class TupianzjPipeline:
    def process_item(self, item, spider):

        for i in range(0,len(item['picurl'])):

            thispic = item['picurl'][i]
            trueurl = thispic
            localpath = "D:/data/zhuangxiu/" + '[' + time.strftime("%Y-%m-%d") + ']' + item['title'][
                i] + '.jpg'
            #localpath = "D:/data/zhuangxiu/" +'[' +time.strftime("%Y-%m-%d %A %H:%M:%S")+']'+ item['title'][i] + '.jpg'
            urllib.request.urlretrieve(trueurl,filename=localpath)

        return item


    #https://img.lianzhixiu.com/uploads/allimg/200828/30-200RQ552540-L.jpg
    #https://img.lianzhixiu.com/uploads/allimg/200828/30-200RQ552540-L.jpg
    #https://img.lianzhixiu.com/uploads/allimg/200828/30-200RQ552540-L.jpg
